import {Button, Pagination, Radio} from "antd";
import './Footer.less'
import React, {useState} from 'react';
import http from "../../../utils/http";
import store from "../../../store/store";

function Footer(props){
    //获取数据需要的参数，父组件传递
    //数据,请求的数据
    // const [data,setData]=useState([])
    // 选项值
    const [currentNum,setCurrent]=useState(1)
    const [value, setValue] = React.useState(0);
    
    const onChange = e => {
        setValue(e.target.value);
          /*  props.getChildData(
                e.target.value,
                store.count,
                10,
                store.leval,
                store.lowestData,
                store.highestData,
                store.nameData,
                store.type)*/
        console.log("当前状态码："+ e.target.value)
    };
    const ruku=()=>{
        // console.log(store.count,store.type,store.lowestData,store.highestData,store.nameData,store.leval)
        let ids =[]
        if (value==2){
            store.rukuData.forEach(item=>{
                ids.push(item.id)
            })
        }else if (value==3){
            ids=props.setdataId
        }
        console.log(ids)
        props.ruku(value,ids)
    //点击时发送value和id集合，获取数据重新渲染数据
        props.getChildData(1,store.count,10,store.leval,store.lowestData,store.highestData,store.nameData,store.type)
    }
    const pageChange=(page)=>{
        console.log(page)
        setCurrent(page)
        props.getChildData(page,store.count,10,store.leval,store.lowestData,store.highestData,store.nameData,store.type)
    //    获取当前页，每页默认十条，发送请求获取数据
    //    获取数据是值改变page，其他数据不发生改变
    }
    return(
        <div className='rukuControl'>
            <Radio.Group onChange={onChange} value={value} style={{display:"inline"}}>
                <Radio value={1}>今日入库</Radio>
                <Radio value={2}>当前页面</Radio>
                <Radio value={3}>已选结果</Radio>
                <Radio value={4}>所有商品</Radio>
            </Radio.Group>
            <span className='yijianruku'>已选中{props.setdataId.length}件</span>
            <Button type="primary" className="yijianruku" onClick={ruku}>一件{props.text}</Button>
            <Pagination
                current={currentNum}
                defaultCurrent={1}
                total={props.datalength}
                style={{display:"inline"}}
                hideOnSinglePage={true}
                // PageSize={1}
                defaultPageSize={10}
                // pageSizeOptions={1}
                showSizeChanger={false}
                onChange={pageChange}
            />
        </div>
    )
}
export default Footer